﻿/*
    功能：判断浏览器类型及版本
*/
function getBrowser() {
    var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    var s;
    (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
    (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
    (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
    (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
    (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;

    var browserInfo = new Array();
    if (Sys.ie) {
        browserInfo[0] = "ie";
        browserInfo[1] = Sys.ie;
    }
    else if (Sys.firefox) {
        browserInfo[0] = "firefox";
        browserInfo[1] = Sys.firefox;
    }
    else if (Sys.chrome) {
        browserInfo[0] = "chrome";
        browserInfo[1] = Sys.chrome;
    }
    else if (Sys.opera) {
        browserInfo[0] = "opera";
        browserInfo[1] = Sys.opera;
    }
    else if (Sys.safari) {
        browserInfo[0] = "safari";
        browserInfo[1] = Sys.safari;
    }
    else {
        browserInfo = null;
    }

    return browserInfo;
}

/*
    功能：去空格
*/
String.prototype.Trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.LTrim = function() {
    return this.replace(/(^\s*)/g, "");
}

String.prototype.RTrim = function() {
    return this.replace(/(\s*$)/g, "");
}  